package routers

import (
	"github.com/gin-gonic/gin"

	"github.com/EDDYCJY/go-gin-example/pkg/setting"
	"github.com/EDDYCJY/go-gin-example/routers/api/v1"
)

func InitRouter() *gin.Engine {
	r := gin.New()

	r.Use(gin.Logger())

	r.Use(gin.Recovery())

	gin.SetMode(setting.RunMode)
	// 绑定路由规则，执行函数
	// r.GET("/test", func(c *gin.Context) {
	// 	c.JSON(200, gin.H{
	// 		"message": "test",
	// 	})
	// })

	//注册路由
	apiv1 := r.Group("/api/v1")
	{

		//获取标签列表
		apiv1.GET("/tags", v1.GetTags)
		//新建标签
		apiv1.POST("/tags", v1.AddTags)
		//更新指定标签
		apiv1.PUT("/tags/:id", v1.EditTags)
		//删除指定标签
		apiv1.DELETE("/tags/:id", v1.DeleteTags)

	}

	return r
}
